#region License
// /* **************************************************************
// * Copyright (C) intex Consulting GmbH - All Rights Reserved    *
// *--------------------------------------------------------------*
// * Unauthorized copying of this file, via any medium is         *
// * strictly prohibited                                          *
// *--------------------------------------------------------------*
// * Proprietary and confidential                                 *
// *--------------------------------------------------------------*
// * Dissasembling/modifications strictly prohibited!             *
// ***************************************************************/
#endregion

using System;
using System.Collections.Generic;
using System.Linq;

namespace ComHlp.ContentClasses.VirtualControls.ContextMenu
{
    /// <summary> intex context menu (holding all entries) </summary>
    public class ItxContextMenu : ICloneable
    {
        /// <summary> context menu entries </summary>
        public List<ItxContextMenuItem> Entrys { private set; get; } = new List<ItxContextMenuItem>();

        /// <summary> cmenu is only saved or directly displayed? </summary>
        public bool IsDirectlyDisplayed { get; set; } = true;

        public ItxContextMenu Clone()
        {
            ItxContextMenu itxContextMenu = MemberwiseClone() as ItxContextMenu;
            if (itxContextMenu == null)
                return null;

            List<ItxContextMenuItem> clonedItems = new List<ItxContextMenuItem>(itxContextMenu.Entrys.Count);
            if (itxContextMenu.Entrys.Count > 0)
                clonedItems.AddRange(itxContextMenu.Entrys.Select(x => x.Clone()));
            Entrys = clonedItems;

            return itxContextMenu;
        }

        object ICloneable.Clone()
        {
            return Clone();
        }
    }
}